import pygame


class StatusBar:
    def __init__(self, screen, position, values: dict):
        self.screen = screen
        self.position = position
        self.values = values
        self.font = pygame.font.SysFont("方正粗黑宋简体", 24)  # 设置状态栏字体

    def update(self, values):
        # 更新状态栏数值
        self.values = values

    def draw(self):
        # 绘制状态栏
        x, y = self.position
        for label, value in self.values.items():
            text = f"{label}: {value}"
            rendered_text = self.font.render(text, True, (0, 0, 0))  # 设置字体颜色为白色
            self.screen.blit(rendered_text, (x, y))  # 绘制文本
            x += rendered_text.get_width() + 10  # 设置下一个文本的横坐标
